<template>
  <app-home>
    <div slot="main">
      <app-table :datas="msg" ref="clickRemove"></app-table>
    </div>
  </app-home>
</template>
<script>
// let moment=require('moment')
// import {validateURL} from "@/utils/validate"
import Home from "@/views/home";
import table from "@/components/table.vue";
export default {
  components: {
    "app-home": Home,
    "app-table": table
  },
  data() {
    return {
      msg:{
        deleBtn: false,
      columns: [
        {
          type: "selection",
          width: 60,
          align: "center"
        },
        {
          title: "用户",
          key: "username"
        },
        {
          title: "管理员权限",
          key: "power",
          width:"100"
        },
        {
          title: "密码",
          key: "password"
        },
        {
          title: "邮箱",
          key: "email"
        },
        {
          title: "性别",
          key: "sex",
          render: (h, params) => {
            if (params.row.sex) {
              return h("div", "男");
            } else {
              return h("div", "女");
            }
          }
        },
        {
          title: "年龄",
          key: "age"
        },
        {
          title: "详细地址",
          key: "address",
          width:"90"
        },
        {
          title: "找回账号问题",
          key: "problem",
          width:"110"
          // render: (h, params) => {
          //   return h("div", [params.row.problem]);
          // }
        },
        {
          title: "爱好",
          key: "hobbies",
          render: (h, params) => {
            return h("div", [params.row.hobbies.join()]);
          }
        },

        {
          title: "注册时间",
          key: "reg_data",
          width:"90"
          // render:(h,params)=>{
          //    return h('div',[moment(params.row.reg_data).format('YYYY-MM-DD')])
          // }
        },

        {
          title: "操作",
          key: "action",
          width: 150,
          align: "center",
          render: (h, params) => {
            return h("div", [
              h(
                "router-link",
                {
                  props: {
                    tag:"Button",
                    to:{name:"userupdata",params:{id:params.row._id}}
                  },
                  style: {
                    marginRight: "5px"
                  }
                },
                "编辑"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "error",
                    size: "small"
                  },
                  on: {
                    click: () => {
                      //通过子组件进行注册ref,传递事件
                      this.$refs.clickRemove.remove(params.row._id);
                    }
                  }
                },
                "删除"
              )
            ]);
          }
        }
      ],
      rows: [],//数据数组
      total: 0,//总页数
      page: 1,//当前所在页
      limit: 10,//默认限制条数
      selectionArray:[],//多个删除数组,
      UserDelete:"UserDelete",//删除单项用户函数
      UserList:"UserList",//获取用户数据函数
      UserRemoves:"UserRemoves"//移除多个用户数据函数
      }
    }
  }
};
</script>
